package iceworld.fernado.resource;

import iceworld.fernado.util.SystemResource;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class SysConfig {

	private static final Map<String, String> map = new HashMap<String, String>();
	
	static {
		Properties props = new Properties();
		String file = SystemResource.getInstance().getProjectFolder() + "resource/" + "sysConfig.properties";
		InputStream is;
		try {
			is = new FileInputStream(file);
			props.load(is);
		} catch (FileNotFoundException e) {
		} catch (IOException e) {
		}
		if (null != props) {
			for (Map.Entry<Object, Object> me: props.entrySet()) {
				map.put((String) me.getKey(), (String) me.getValue());
			}
		}
	}
	
	private static final SysConfig instance = new SysConfig();
	
	public static final SysConfig getInstance() {
		return instance;
	}
	
	private SysConfig() {
	}
	
	
	public Map<String, String> getProperties() {
		return map;
	}
	
	public String getValue(String key) {
		return map.get(key);
	}
	
}
